{extend name="public/base" /}
{block name="css"}
<style>

  .container-fluid {
    background-color: #ffffff;
  }

  .mx-auto {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .formItem {
    display: flex;
    flex-direction: row;
    align-items: center;
  }

  .formItem > div {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 80vw;
    margin-top: 10px;
  }

  .formItem > div > label{
    height: 35px;
    line-height: 42px;
  }

  input {
    border:1px solid #e6e6e6;
    padding-left: 5px;
    height: 35px;
    line-height: 35px;
    width: 67%;
  }

</style>
{/block}
{block name="main"}
<section class="container-fluid main-container">
  <div class="mx-auto" style="max-width: 1200px;">
    <div style="color: #1C2857;margin-top: 40px;font-size: 22px; font-weight: bold">提前算一算，美学整配需要多少钱</div>
    <div style="color: #1C2857;margin: 10px auto 10px; font-size: 16px">- 今天您是第126位业主获取报价 -</div>
    <div class="formItem">
      <div>
      <label><span style="visibility: hidden">*</span>楼盘名称：</label>
      <input type="text" id="building" placeholder="请填写您的楼盘名称">
      </div>
    </div>
    <div class="formItem">
      <div>
      <label><span style="visibility: hidden">*</span>房屋户型：</label>
      <input type="text" id="housing" placeholder="例如3室2厅2卫">
      </div>
    </div>
    <div class="formItem">
      <div>
      <label><span style="visibility: hidden">*</span>建筑面积：</label>
      <input type="number" id="area" placeholder="" style="width: 50%;margin-right: 10px">
      ㎡
      </div>
    </div>
    <div class="formItem">
      <div>
      <label><span style="color: #B94047">*</span>手机号码：</label>
      <input type="tel" id="mobile" placeholder="请填写您的手机号码">
      </div>
    </div>
    <button id="submit" style="margin: 20px 0 10px;background: #1C2857; border-radius: 3px; color: #ffffff; border: 0;width: 70%; height: 40px">开始计算</button>
    <div style="color: #1C2857; font-size: 12px">*为了您的权益，您的隐私将被严格保密</div>
  </div>

  <img alt="" class="img-fluid" style="margin-top: 30px;" src="https://res.bestyoujia.com/web/ZMYJ/activities/land202004/mobile/zijin.png">
</section>
{/block}
{block name="js"}
<script>
    initWxShare('提前算一算，美学整配需要多少钱', '致美优家，成都首家专注精装房一站式美学整配带的优质服务商');

    $('#submit').on('click', function () {
        window.page_position = '精装房报名页';

        const building = $('#building').val() || '';
        const area = $('#area').val() || '';
        const housing = $('#housing').val() || '';
        const mobile = $('#mobile').val();

        const mobileStatus = validMobile(mobile);

        switch (mobileStatus) {
            case 1:
                $.showLoading("预约中");

                const data = {
                    mobile,
                    area,
                    housing,
                    building,
                };

                doAppointment(
                    data,
                    function(res) {
                        console.log('onAppointmentSuccess', res);
                        const { data = '' } = res;
                        if (data) {
                            buryingPoint('APPOINTMENT', data);
                            $.hideLoading();
                            $.toast("预约成功");
                            resetForm();
                        }
                    },
                    function(err) {
                        console.log('onAppointmentError', err);
                        $.hideLoading();
                        $.toast(err, "text");
                        resetForm();
                    }
                );
                break;
            case 2:
                $.toast("手机号码格式不正确", "forbidden");
                break;
            case 3:
                $.toast("手机号码不能为空", "forbidden");
                break;
        }
    });

    function resetForm() {
        $('#building').val('');
        $('#area').val('');
        $('#housing').val('');
        $('#mobile').val('');
    }
</script>
{/block}